package cn.tedu.sp04.feign;

import cn.tedu.sp01.pojo.User;
import cn.tedu.sp01.util.JsonResult;
import org.springframework.stereotype.Component;

/**
 * @author 张琪
 * @date 2020/12/22
 * @describe
 */
@Component
public class UserClientFB implements UserClient{
    @Override
    public JsonResult<User> getUser(Integer userId) {
//        模拟返回缓存数据
        if (Math.random() < 0.5) {
            return JsonResult.ok().data(new User(8,"缓存用户8","缓存密码8"));
        }


        return JsonResult.err().msg("获取用户信息失败");
    }

    @Override
    public JsonResult<?> addScore(Integer userId, Integer score) {
        return JsonResult.err().msg("增加积分失败");
    }
}
